import unittest
from HTMLTestRunner import HTMLTestRunner
import time
import os

# loader
loader = unittest.defaultTestLoader.discover('test_cases', 'test_*')
# suite

# runner
report = os.path.abspath('report')
file_name = time.strftime('%Y-%m-%d %H-%M-%S') + '-demo.html'
file_path = os.path.join(report, file_name)

with open(file_path, 'wb') as f:
    runner = HTMLTestRunner(
        title='测试报告标题',
        stream=f,
        verbosity=2
    )
    runner.run(loader)

